//package cn.jeefast.resthz.webservice.demo;
//
//
//import cn.jeefast.common.utils.DateUtil;
//import cn.jeefast.common.utils.PropertiesUtils;
//import cn.jeefast.resthz.webservice.entity.CarFreeCarrier;
//import com.wondersgroup.cuteinfo.client.exchangeserver.exchangetransport.dao.IMessageTransporterDAO;
//import com.wondersgroup.cuteinfo.client.exchangeserver.exchangetransport.factory.ITransportClientFactory;
//import com.wondersgroup.cuteinfo.client.exchangeserver.exchangetransport.impl.USendRequset;
//import com.wondersgroup.cuteinfo.client.exchangeserver.exchangetransport.impl.USendResponse;
//import com.wondersgroup.cuteinfo.client.exchangeserver.usersecurty.UserToken;
//import com.wondersgroup.cuteinfo.client.util.UserTokenUtils;
//import java.io.IOException;
//import java.text.SimpleDateFormat;
//import java.util.Calendar;
//import java.util.Properties;
//
//public class NStest {
//
//  /**
//   * @param args
//   * @throws IOException
//   */
//  public static void main(String[] args) throws IOException {
//    //设置证书文件
//    //System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
//    //String truststoreFile = System.getenv("JAVA_HOME") + "/jre/lib/security/" + "cuteinfo_client.trustStore";
//    //System.setProperty("javax.net.ssl.trustStore", truststoreFile);
//
//    //读取配置文件
//    Properties properties = PropertiesUtils.PROPERTIES
//        .getProperties("config/client_demo.properties");
//
//    String targetURL = properties.getProperty("targetURL");
//    String securityURL = properties.getProperty("securityURL");
//
//    IMessageTransporterDAO transporter = null;
//    try {
//      //首先需要通过平台的认证服务，使用物流交换代码和密码取得令牌。有两种方式，选一种即可
//      //第一种方式，调用数据交换的令牌认证服务
////			UserSecurityClient security= UserSecurityClientFactory.createUserSecurityClient(securityURL);
////			UserToken token=security.authenticate(properties.getProperty("username"), properties.getProperty("password"));
////			System.out.println("tokenid:"+token.getTokenID());
//
//      //第二种方式，调用统一认证的令牌认证服务
//      UserToken token = UserTokenUtils
//          .getTicket(properties.getProperty("username"), properties.getProperty("password"),
//              properties.getProperty("resource"), properties.getProperty("authURL"));
//      System.out.println("tokenid:" + token.getTokenID());
//
//      //接下来需要设置目标地址，发送报文的内容，包括报文类型Actiontype和具体报文xml
//      USendRequset sendReq = new USendRequset();
//      sendReq.setToaddress(properties.getProperty("toaddress").split(","));
//
//      //设置待发送的附件
//      //File f = new File("c:\\warning.sql");
//      //System.out.println("[" + f.getName() + "]文件大小为：" + FileUtils.convertFileSize(f.length()));
//      //sendReq.setFile(f);
//
//      //sendReq.setSendRequestTypeSimpleData("ZJWL_LOGINK_BZGL_DataUnitDownloadRequest", "DataElementID", "3229");
//
////			sendReq.setSendRequestTypeFILE("ZJWL_LOGINK_FAQ_InfoIssueRequest", FileUtils.toByteArray("c:\\warning.sql"));
//
//      //设置待发送的业务报文
////			String xml = getMessageToXML();
//      CarFreeCarrier cfc = new CarFreeCarrier();
//      //装载数据
//      cfc.setDocumentName("无车承运人电子路单");
//      cfc.setDocumentVersionNumber("2015WCCYR");
//      cfc.setSenderCode("21205");
//      cfc.setRecipientCode("14057");
//      cfc.setMessageSendingDateTime(DateUtil.getCurrentDateTime(13));
//      cfc.setMessageFunctionCode("9");
//      cfc.setOriginalDocumentNumber("31314534223");
//      cfc.setShippingNoteNumber("532135");
//      cfc.setCarrier("浙江未名物流有限公司");
//      cfc.setUnifiedSocialCreditIdentifier("11991000010647510A");
//      cfc.setCPermitNumber("310112002939");
//      cfc.setConsignmentDateTime(DateUtil.getCurrentDateTime(13));
//      cfc.setBusinessTypeCode("1002996");
//      cfc.setDespatchActualDateTime(DateUtil.getCurrentDateTime(13));
//      cfc.setGoodsReceiptDateTime(DateUtil.getCurrentDateTime(13));
//      cfc.setConsignor("浙江新华书店");
//      cfc.setPersonalIdentityDocument("330102198402124417");
//      cfc.setPlaceOfLoading("浙江省杭州市江干区");
//      cfc.setCCountrySubdivisionCode("330104");
//      cfc.setConsignee("台州新华书店");
//      cfc.setGoodsReceiptPlace("浙江省台州市椒江区");
//      cfc.setDCountrySubdivisionCode("331002");
//      cfc.setTotalMonetaryAmount(430.012+"");
//      cfc.setRemark("人民币");
//      cfc.setLicensePlateTypeCode("01");
//      cfc.setVehicleNumber("浙A32153");
//      cfc.setVehicleClassificationCode("H01");
//      cfc.setVehicleTonnage(20.00+"");
//      cfc.setRoadTransportCertificateNumber("330111003790");
//      cfc.setTrailerVehiclePlateNumber("浙RR527挂");
//      cfc.setOwner("温州市侯海货运有限公司");
//      cfc.setDPermitNumber("330301000307");
//      cfc.setNameOfPerson("张三");
//      cfc.setQualificationCertificateNumber("431224198708273098");
//      cfc.setTelephoneNumber("15167338765");
//      cfc.setDescriptionOfGoods("教科书");
//      cfc.setCargoTypeClassificationCode("999");
//      cfc.setGoodsItemGrossWeight(151.333+"");
//      cfc.setCube(11.3333+"");
//      cfc.setTotalNumberOfPackages(12+"");
//      cfc.setFreeText("文本");
//
//      String xml = getMessageToXML2(cfc);
////      sendReq.setSendRequestTypeXML("ZJWL_LOGINK_FAQ_InfoIssueRequest", xml);
//      sendReq.setSendRequestTypeXML("LOGINK_CN_FREIGHTBROKER_WAYBILL", xml);
//
//      //最后，调用平台提供的发送服务发送报文
//      transporter = ITransportClientFactory.createMessageTransporter(token, targetURL);
//
//      long start = System.currentTimeMillis();
//      USendResponse response = transporter.send(sendReq);
//      long end = System.currentTimeMillis();
//      System.out.println("发送耗时：" + (end - start) + "毫秒，报文长度" + xml.getBytes().length);
//
//      if (response.isSendResult()) {
//        System.out.println("send success");
//      } else {
//        //错误的情况下，会返回异常代码以及异常信息。异常代码请参照《3.2 共建指导性文件：交换接入》中的异常代码信息
//        System.out.println("send error");
//        System.out.println(response.getGenericFault().getCode());
//        System.out.println(response.getGenericFault().getMessage());
//      }
//
//    } catch (Exception e) {
//      e.printStackTrace();
//    }
//  }
//
//  public static String getActionTypeToXML() {
//    Calendar cc = Calendar.getInstance();
//    SimpleDateFormat sf = new SimpleDateFormat("YYYYMMDDhhmmss");
//    String xml = "";
//    xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
//    xml = xml + "<Root>";
//    xml = xml + "<baseInfo>";
//    xml = xml + "<shipperName>托运方</shipperName>";
//    xml = xml + "<wldm>托运方物流交换代码</wldm>";
//    xml = xml + "<acceptTime>2009-11-17 20:20</acceptTime>";
//    xml = xml + "<sourceAddress>起始地</sourceAddress>";
//    xml = xml + "<unloadAddress>目的地</unloadAddress>";
//    xml = xml + "<arriveTime>到达时间</arriveTime>";
//    xml = xml + "<opinion>评价信息（默认获用户好评）</opinion>";
//    xml = xml + "<sourceSystem>001</sourceSystem>";
//    xml = xml + "</baseInfo>";
//    xml = xml + "</Root>";
//    return xml;
//  }
//
//  public static String getMessageToXML() {
//    String xml = "";
//    xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
//    xml = xml + "<Root>";
//    xml = xml + "<Header>";
//    xml = xml
//        + "<MessageReferenceNumber>{823FD511-CAA1-427e-8DC7-AA4F17CA0083}</MessageReferenceNumber>";
//    xml = xml + "<DocumentName>物流通用软件客户端意见上传</DocumentName>";
//    xml = xml + "<DocumentVersionNumber>V3.0</DocumentVersionNumber>";
//    xml = xml + "<SenderCode>768</SenderCode>";
//    xml = xml + "<MessageSendingDateTime>20120301093318</MessageSendingDateTime>";
//    xml = xml + "</Header>";
//    xml = xml + "<Body>";
//    xml = xml + "<QuestionCode>20120301001</QuestionCode>";
//    xml = xml + "<InfoTitle>联调测试</InfoTitle>";
//    xml = xml + "<FreeText>收到请回个话，谢谢</FreeText>";
//    xml = xml + "<IssueDateTime>20120301093253</IssueDateTime>";
//    xml = xml + "<IssuerName>王贤进</IssuerName>";
//    xml = xml + "<LogisticsExchangeCode>768</LogisticsExchangeCode>";
//    xml = xml
//        + "<InformationSystemNumber>Logink-RS-1002-331-hoteamsoft-V3.0</InformationSystemNumber>";
//    xml = xml + "<InfomationIdentity>20120301001</InfomationIdentity>";
//    xml = xml + "</Body>";
//    xml = xml + "</Root>";
//    return xml;
//  }
//
//  public static String getMessageToXML2(CarFreeCarrier c) {
//    StringBuffer sb = new StringBuffer();
//
//    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//    sb.append(
//        "<MessageReferenceNumber>" + c.getMessageReferenceNumber() + "</MessageReferenceNumber>");
//    sb.append("<DocumentName>" + c.getDocumentName() + "</DocumentName>");
//    sb.append(
//        "<DocumentVersionNumber>" + c.getDocumentVersionNumber() + "</DocumentVersionNumber>");
//    sb.append("<SenderCode>" + c.getSenderCode() + "</SenderCode>");
//    sb.append("<RecipientCode>" + c.getRecipientCode() + "</RecipientCode>");
//    sb.append(
//        "<MessageSendingDateTime>" + c.getMessageSendingDateTime() + "</MessageSendingDateTime>");
//    sb.append("<MessageFunctionCode>" + c.getMessageFunctionCode() + "</MessageFunctionCode>");
//    sb.append("</Header>");
//    sb.append("<Body>");
//    sb.append(
//        "<OriginalDocumentNumber>" + c.getOriginalDocumentNumber() + "</OriginalDocumentNumber>");
//    sb.append("<ShippingNoteNumber>" + c.getShippingNoteNumber() + "</ShippingNoteNumber>");
//    sb.append("<Carrier>" + c.getCarrier() + "</Carrier>");
//    sb.append("<UnifiedSocialCreditIdentifier>" + c.getUnifiedSocialCreditIdentifier()
//        + "</UnifiedSocialCreditIdentifier>");
//    sb.append("<PermitNumber>" + c.getCPermitNumber() + "</PermitNumber>");
//    sb.append("<ConsignmentDateTime>" + c.getConsignmentDateTime() + "</ConsignmentDateTime>");
//    sb.append("<BusinessTypeCode>" + c.getBusinessTypeCode() + "</BusinessTypeCode>");
//    sb.append(
//        "<DespatchActualDateTime>" + c.getDespatchActualDateTime() + "</DespatchActualDateTime>");
//    sb.append("<GoodsReceiptDateTime>" + c.getGoodsReceiptDateTime() + "</GoodsReceiptDateTime>");
//    sb.append("<ConsignorInfo>");
//    sb.append("<Consignor>" + c.getConsignor() + "</Consignor>");
//    sb.append("<PersonalIdentityDocument>" + c.getPersonalIdentityDocument()
//        + "</PersonalIdentityDocument>");
//    sb.append("<PlaceOfLoading>" + c.getPlaceOfLoading() + "</PlaceOfLoading>");
//    sb.append(
//        "<CountrySubdivisionCode>" + c.getCCountrySubdivisionCode() + "</CountrySubdivisionCode>");
//    sb.append("</ConsignorInfo>");
//    sb.append("<ConsigneeInfo>");
//    sb.append("<Consignee>" + c.getConsignee() + "</Consignee>");
//    sb.append("<GoodsReceiptPlace>" + c.getGoodsReceiptPlace() + "</GoodsReceiptPlace>");
//    sb.append(
//        "<CountrySubdivisionCode>" + c.getDCountrySubdivisionCode() + "</CountrySubdivisionCode>");
//    sb.append("</ConsigneeInfo>");
//    sb.append("<PriceInfo>");
//    sb.append("<TotalMonetaryAmount>" + c.getTotalMonetaryAmount() + "</TotalMonetaryAmount>");
//    sb.append("<Remark>" + c.getRemark() + "</Remark>");
//    sb.append("</PriceInfo>");
//    sb.append("<VehicleInfo>");
//    sb.append("<LicensePlateTypeCode>" + c.getLicensePlateTypeCode() + "</LicensePlateTypeCode>");
//    sb.append("<VehicleNumber>" + c.getVehicleNumber() + "</VehicleNumber>");
//    sb.append("<VehicleClassificationCode>" + c.getVehicleClassificationCode()
//        + "</VehicleClassificationCode>");
//    sb.append("<VehicleTonnage>" + c.getVehicleTonnage() + "</VehicleTonnage>");
//    sb.append("<RoadTransportCertificateNumber>" + c.getRoadTransportCertificateNumber()
//        + "</RoadTransportCertificateNumber>");
//    sb.append("<TrailerVehiclePlateNumber>" + c.getTrailerVehiclePlateNumber()
//        + "</TrailerVehiclePlateNumber>");
//    sb.append("<Owner>" + c.getOwner() + "</Owner>");
//    sb.append("<PermitNumber>" + c.getDPermitNumber() + "</PermitNumber>");
//    sb.append("<Driver>");
//    sb.append("<NameOfPerson>" + c.getNameOfPerson() + "</NameOfPerson>");
//    sb.append("<QualificationCertificateNumber>" + c.getQualificationCertificateNumber()
//        + "</QualificationCertificateNumber>");
//    sb.append("<TelephoneNumber>" + c.getTelephoneNumber() + "</TelephoneNumber>");
//    sb.append("</Driver>");
//    sb.append("<GoodsInfo>");
//    sb.append("<DescriptionOfGoods>" + c.getDescriptionOfGoods() + "</DescriptionOfGoods>");
//    sb.append("<CargoTypeClassificationCode>" + c.getCargoTypeClassificationCode()
//        + "</CargoTypeClassificationCode>");
//    sb.append("<GoodsItemGrossWeight>" + c.getGoodsItemGrossWeight() + "</GoodsItemGrossWeight>");
//    sb.append("<Cube>" + c.getCube() + "</Cube>");
//    sb.append(
//        "<TotalNumberOfPackages>" + c.getTotalNumberOfPackages() + "</TotalNumberOfPackages>");
//    sb.append("</GoodsInfo>");
//    sb.append("</VehicleInfo>");
//    sb.append("<FreeText>" + c.getFreeText() + "</FreeText>");
//    sb.append("</Body>");
//    sb.append("</Root>");
//
//    return sb.toString();
//  }
//
//}
//
//
//
//
//
//
//
